home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / json / tests / test_fail.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  3KB  |  78 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. from json.tests import PyTest, CTest
  5. JSONDOCS = [
  6.     '"A JSON payload should be an object or array, not a string."',
  7.     '["Unclosed array"',
  8.     '{unquoted_key: "keys must be quoted"}',
  9.     '["extra comma",]',
  10.     '["double extra comma",,]',
  11.     '[   , "<-- missing value"]',
  12.     '["Comma after the close"],',
  13.     '["Extra close"]]',
  14.     '{"Extra comma": true,}',
  15.     '{"Extra value after close": true} "misplaced quoted value"',
  16.     '{"Illegal expression": 1 + 2}',
  17.     '{"Illegal invocation": alert()}',
  18.     '{"Numbers cannot have leading zeroes": 013}',
  19.     '{"Numbers cannot be hex": 0x14}',
  20.     '["Illegal backslash escape: \\x15"]',
  21.     '[\\naked]',
  22.     '["Illegal backslash escape: \\017"]',
  23.     '[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]',
  24.     '{"Missing colon" null}',
  25.     '{"Double colon":: null}',
  26.     '{"Comma instead of colon", null}',
  27.     '["Colon instead of comma": false]',
  28.     '["Bad value", truth]',
  29.     "['single quote']",
  30.     '["\ttab\tcharacter\tin\tstring\t"]',
  31.     '["tab\\   character\\   in\\  string\\  "]',
  32.     '["line\nbreak"]',
  33.     '["line\\\nbreak"]',
  34.     '[0e]',
  35.     '[0e+]',
  36.     '[0e+-1]',
  37.     '{"Comma instead if closing brace": true,',
  38.     '["mismatch"}',
  39.     u'["A\x1fZ control characters in string"]']
  40. SKIPS = {
  41.     1: 'why not have a string payload?',
  42.     18: "spec doesn't specify any nesting limitations" }
  43.  
  44. class TestFail(object):
  45.     
  46.     def test_failures(self):
  47.         for idx, doc in enumerate(JSONDOCS):
  48.             idx = idx + 1
  49.             if idx in SKIPS:
  50.                 self.loads(doc)
  51.                 continue
  52.             
  53.             try:
  54.                 self.loads(doc)
  55.             except ValueError:
  56.                 continue
  57.  
  58.             self.fail('Expected failure for fail{0}.json: {1!r}'.format(idx, doc))
  59.         
  60.  
  61.     
  62.     def test_non_string_keys_dict(self):
  63.         data = {
  64.             'a': 1,
  65.             (1, 2): 2 }
  66.         self.assertRaises(TypeError, self.dumps, data)
  67.         self.assertRaises(TypeError, self.dumps, data, indent = True)
  68.  
  69.  
  70.  
  71. class TestPyFail(TestFail, PyTest):
  72.     pass
  73.  
  74.  
  75. class TestCFail(TestFail, CTest):
  76.     pass
  77.  
  78.